//
//  BaseViewController.swift
//  JKWeiBo
//
//  Created by 王冲 on 2017/5/27.
//  Copyright © 2017年 希爱欧科技有限公司. All rights reserved.
//

import UIKit

class BaseViewController: UIViewController,VisitorViewDelete {

    // 定义一个变量保存当前用户是否登录
    var userLogin = UserAccount.userLogin()
    
    var vistorView: VisitorView?
    
    
    override func loadView() {
        
        userLogin ? super.loadView() : setViewUp()
    }
    
    // MARK: 内部控制方法
    /*
     * 创建未登录界面
     */
    private func  setViewUp(){
        
        print("创建未登录界面")
        // 1.初始化未登录界面
        let customView = VisitorView()
        customView.delegate = self
        customView.backgroundColor = UIColor.JKGlobalColor()
        view = customView
        vistorView = customView
        // 2.设置导航条未登录按钮
        // 设置导航条的颜色 最好是设置外观来设置全局的颜色
        //navigationController?.navigationBar.tintColor = UIColor.orange
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.plain, target: self,action: #selector(BaseViewController.registerWillClick))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.plain, target: self,action: #selector(BaseViewController.logionWillClick))
    }
    
    // MARK: 登录按钮的点击事件
    func logionWillClick() {
        
        print("控制器里面的登录")
        // 弹出登录界面
        let oAuthViewController = OAuthViewController()
        let nav = UINavigationController(rootViewController: oAuthViewController)
        present(nav, animated: true, completion: nil)
        
    }
    // MARK: 注册按钮的点击事件
    func registerWillClick() {
       
        print("控制器里面的注册")
        
     
    }

}
